package com.xique.door.service.impl;


import com.xique.common.core.text.Convert;
import com.xique.door.bean.domain.ElevatorEvent;
import com.xique.door.bean.search.ElevatorOpenAndCloseDoorTimesSearch;
import com.xique.door.bean.vo.elevator.ElevatorEventStatisticVO;
import com.xique.door.mapper.ElevatorEventMapper;
import com.xique.door.service.IElevatorEventService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shd
 * @create 2021/10/14 9:58
 */
@Service
public class ElevatorEventServiceImpl implements IElevatorEventService
{
    @Autowired
    private ElevatorEventMapper elevatorEventMapper;

    /**
     * 查询事件集合
     *
     * @param id 事件集合ID
     * @return 事件集合
     */
    @Override
    public ElevatorEvent selectElevatorEventById(Long id)
    {
        return elevatorEventMapper.selectElevatorEventById(id);
    }

    @Override
    public ElevatorEvent selectLastElevatorEventByElvId(Long elvId) {
        return elevatorEventMapper.selectLastElevatorEventByElvId(elvId);
    }

    /**
     * 查询事件集合列表
     *
     * @param elevatorEvent 事件集合
     * @return 事件集合
     */
    @Override
    public List<ElevatorEvent> selectElevatorEventList(ElevatorEvent elevatorEvent)
    {
        return elevatorEventMapper.selectElevatorEventList(elevatorEvent);
    }

    @Override
    public long selectElevatorEventListCount(ElevatorEvent elevatorEvent) {
        return elevatorEventMapper.selectElevatorEventListCount(elevatorEvent);
    }

    @Override
    public long selectElevatorEventOpenAndCloseDoorTimes(ElevatorOpenAndCloseDoorTimesSearch search) {
        return elevatorEventMapper.selectElevatorEventOpenAndCloseDoorTimes(search);
    }

    @Override
    public long selectElevatorEventOpenAndCloseDoorTimesByElvIds(List<Long> elvIds) {
        return elevatorEventMapper.selectElevatorEventOpenAndCloseDoorTimesByElvIds(elvIds);
    }

    /**
     * 新增事件集合
     *
     * @param elevatorEvent 事件集合
     * @return 结果
     */
    @Override
    public int insertElevatorEvent(ElevatorEvent elevatorEvent)
    {
        return elevatorEventMapper.insertElevatorEvent(elevatorEvent);
    }

    @Override
    public int insertElevatorEvents(List<ElevatorEvent> list) {
        if (CollectionUtils.isEmpty(list)) {
            return 1;
        }
        return elevatorEventMapper.batchInsertElevatorEvents(list);
    }

    /**
     * 修改事件集合
     *
     * @param elevatorEvent 事件集合
     * @return 结果
     */
    @Override
    public int updateElevatorEvent(ElevatorEvent elevatorEvent)
    {
        return elevatorEventMapper.updateElevatorEvent(elevatorEvent);
    }

    /**
     * 删除事件集合对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteElevatorEventByIds(String ids)
    {
        return elevatorEventMapper.deleteElevatorEventByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除事件集合信息
     *
     * @param id 事件集合ID
     * @return 结果
     */
    @Override
    public int deleteElevatorEventById(Long id)
    {
        return elevatorEventMapper.deleteElevatorEventById(id);
    }

    @Override
    public List<ElevatorEventStatisticVO> selectElevatorEventStatisticByElvId(Long elvId) {
        return elevatorEventMapper.selectElevatorEventStatisticByElvId(elvId);
    }
}